package com.bolingcavalry.crm.sysdict.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.base.ResponseResult;
import com.bolingcavalry.crm.sysdict.SysDictItemMapper;
import com.dto.fault.SysDictItemDTO;
import com.entity.fault.SysDictItem;
import com.vo.fault.SysDictItemVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDictItem> implements com.bolingcavalry.crm.sysdict.service.SysDictItemServiceImpl {
    @Autowired
    private SysDictItemMapper sysDictItemMapper;

    @Override
    public ResponseResult add(SysDictItemDTO faultPhenomenonDTO) {
        return null;
    }

    @Override
    public ResponseResult deleteById(Long id) {
        return null;
    }

    @Override
    public ResponseResult batchDelete(List<Long> ids) {
        return null;
    }

    @Override
    public ResponseResult update(SysDictItemDTO faultPhenomenonDTO) {
        return null;
    }

    @Override
    public SysDictItemVO getById(Long id) {
        return null;
    }

    @Override
    public IPage<SysDictItemVO> getByConditions(Integer pageNum, Integer pageSize, String faultDescription) {
        return null;
    }

    @Override
    public List<SysDictItemVO> getAllList() {
        List<SysDictItem> faultPhenomenon = sysDictItemMapper.selectAll();
        return faultPhenomenon.stream().map(faultPhenomenon1 -> {
            SysDictItemVO faultPhenomenonVO = new SysDictItemVO();
            BeanUtils.copyProperties(faultPhenomenon1, faultPhenomenonVO);
            return faultPhenomenonVO;
        }).toList();

    }

    @Override
    public List<String> getAllFaultDescription() {
        LambdaQueryWrapper<SysDictItem> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(SysDictItem::getDictCode, "FAULT_PHENOMENON");
        queryWrapper.select(SysDictItem::getItemName);
        List<SysDictItem> faultPhenomenon = sysDictItemMapper.selectList(queryWrapper);
        return faultPhenomenon.stream().map(faultPhenomenon1 -> faultPhenomenon1.getItemName()).toList();
    }

    @Override
    public List<String> getAllCategory() {
        LambdaQueryWrapper<SysDictItem> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(SysDictItem::getDictCode, "PROBLEM_CATEGORY");
        queryWrapper.select(SysDictItem::getItemName);
        List<SysDictItem> faultPhenomenon = sysDictItemMapper.selectList(queryWrapper);
        return faultPhenomenon.stream().map(faultPhenomenon1 -> faultPhenomenon1.getItemName()).toList();
    }
}
